<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      .modal {
        position: fixed;
        z-index: 999;
        top: 20%;
        left: 50%;
        width: 300px;
        margin-left: -150px;
        background-color: #eee;
      }
    </style>
  </head>
  <body>
    <!-- 熟悉并且会使用 -->
    <!-- vue3新增 -->
    <!-- Teleport组件是将原本在组件内部渲染的内容，“传送”到该组件的 DOM 结构外层的位置去。 -->
    <!-- 有需要对窗口进行全局定位的时候用，对话框，悬浮框，小提示等 -->
    <!-- to disabled -->
    <div id="app">
      <button @click="open = true">Open Modal</button>

      <Teleport to="body" :disabled="false">
        <div v-if="open" class="modal">
          <p>Hello from the modal!</p>
          <button @click="open = false">Close</button>
        </div>
      </Teleport>

      <Teleport to="body">
        <div>B</div>
      </Teleport>
    </div>

    <script src="./Vue3.js"></script>
    <script>
      const { createApp } = Vue;

      createApp({
        data() {
          return {
            open: false,
          };
        },
      }).mount("#app");
    </script>
  </body>
</html>
